package com.xhs.runner;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.net.InetAddress;

/**
 * @desc: 启动控制台打印信息
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/3 23:31
 * @version: JDK 1.8
 */
@Slf4j
@Component
public class DesignRunner implements CommandLineRunner {

    @Value("${server.port}")
    private String port;
    @Value("${spring.application.name}")
    private String serviceName;

    /**
     * @param args
     * @throws Exception
     */
    @Override
    public void run(String... args) throws Exception {
        InetAddress addr = InetAddress.getLocalHost();
        String ipAddr = addr.getHostAddress();
        log.info("http://{}:{}", ipAddr, port);
        log.info("http://localhost:{}", port);
        log.info("--------------------{}服务启动成功--------------------", serviceName);
    }
}
